﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>运费</title>
    <link href="/style/rightdirectory.css" rel="stylesheet" />
    <script src="/script/config.js"></script>
</head>
<style>
    th {
        text-align: center;
    }
    td {
        text-align: center;
    }
   
</style>
<body>
    <div class="view-page">
        <!--搜索区域-->
        <div class="view-search inline">
            <div class="form-inline">
                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">运费名称</span>
                        <input id="query" type="text" class="form-control" data-form="FreightName" placeholder="运费名称">
                    </div>
                </div>

                <div class="form-group col-sm-1">
                    <button type="button" id="btn-search" class="btn btn-primary">
                        <i class="fa fa-search"></i> 搜索
                    </button>
                </div>
            </div>
        </div>
        <div class="view-eidt-btns">
            <a  href="/views/mall/Order/freight/edit.html" class="btn btn-sm">
                <i class="fa fa-plus"></i>添加
            </a>
            <a  href="javascript:;" class="btn btn-sm" data-btn-eidt="/views/mall/Order/freight/edit.html?v=">
                <i class="fa fa-edit"></i>编辑
            </a>
           
        </div>
        <div class="view-data">
            <table id="table" class="table table-bordered table-hover" data-post="">
                <thead>
                    <tr>
                        <th class="checkboxs">
                            <label class="checkbox-reset">
                                <input type="checkbox" data-checked-table="all" />
                            </label>
                        </th>
                        <th>运费名称</th>
                        <th>运费价格</th>
                        <th>运费类型 </th>
                        <th>是否启动 </th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <!--分页条 默认选择id=list-page元素-->
            <div id="list-page" class="view-pagination-page"></div>
        </div>
    </div>   
</body>

</html>
<script type="text/html" id="tp-table">
    {{each list d}}
    <tr data-eidt="{{d.Id}}">
        <td class="checkboxs">
            <label class="checkbox-reset">
                <input type="checkbox" value="{{d.Id}}" data-checked-table="single" />
            </label>
        </td>
        <td>{{d.FreightName}}</td>
        <td>{{d.Price}}</td>
        {{if d.Type==0}}
        <td>包邮</td>
        {{else if d.Type==1}}
        <td>运费模式</td>
        {{/if}}
        {{if d.UseStatus==1}}
        <td>启动</td>
        {{else if d.UseStatus==2}}
        <td>关闭</td>
        {{else}}
        <td>未知</td>
        {{/if}}
        <td>{{d.CreateDate|to_date}}</td>
    </tr>
    {{/each}}
</script>

<script type="text/javascript">
    $(function() {
        function _LoadData() {            
            $.http.json("freightconfig/list",{}, {
                pass: function (d) {
                    console.log(d)
                    $("#table>tbody").append(template("tp-table", {
                        list: d
                    }));
                    },
                    error: function (d) {
                        console.log(d);
                    }
                })
        }
        _LoadData();//初启化
        $("#query").focus(function () { //搜索按钮
            $("#query").keydown(function(e) {
                if (e.keyCode == 13) {
                    _LoadData();
                }
            })
        })
        $("#btn-search").click(function() { //搜索按钮
            _LoadData();
        })

    })
</script>